//*********************************************************
//
//    Copyright (c) Microsoft. All rights reserved.
//    This code is licensed under the Apache License, Version 2.0.
//    THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
//    ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
//    IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
//    PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************

namespace Microsoft.Research.ProvenanceCommon.Model
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using SR = Microsoft.Research.DataLayer;
    using System.Globalization;

    public class ProcessingStatusModel
    {
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="status"></param>
        public ProcessingStatusModel(SR.ProcessingStatus status)
        {
            this.Event = status.Events;
            this.Time = TimeZone.CurrentTimeZone.ToLocalTime(status.PublishedTime);
            this.Details = status.Details;
            this.ActivityName = status.Name;
        }

        /// <summary>
        /// Empty Constructor
        /// </summary>
        public ProcessingStatusModel()
        {
        }

        /// <summary>
        /// Gets or sets workflow, activity, or user event name
        /// </summary>
        public string Event { get; set; }

        /// <summary>
        /// Gets or sets long timestamp when the event is raised in the workflow runtime
        /// </summary>
        public DateTime Time { get; set; }

        /// <summary>
        /// Gets or sets details if any
        /// </summary>
        public string Details { get; set; }

        /// <summary>
        /// The activity name.
        /// </summary>
        public string ActivityName { get; set; }

        /// <summary>
        /// Overridden tostring method. For automation Ids.
        /// </summary>
        /// <returns>The string representation of the object.</returns>
        public override string ToString()
        {
            string automationID = string.Format(CultureInfo.CurrentCulture, "{0}{1}", this.ActivityName, this.Event);
            if (!string.IsNullOrEmpty(automationID))
            {
                return automationID;
            }
            return base.ToString();
        }
    }
}
